// pages/main/choose_course/result_course/result_course.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    list:[
      
    ]
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var choose_class = getApp().globalData.choose_class
    var that=this;
    const db = wx.cloud.database()
    db.collection('class').get({
      success: (res) => {
        let classes =res.data;
        for (let i = classes.length-1, n = 0; i >= 0; i--) {  //遍历数据库对象集合
          if(choose_class.class_name === classes[i].class_name &&
            choose_class.teacher === classes[i].teacher &&
            choose_class.time === classes[i].time &&
            choose_class.week === classes[i].week &&
            choose_class.type === classes[i].type)
          {
            let person = "list["+n+"].person"
            let class_name = "list["+n+"].class"
            let type = "list["+n+"].type"
            let teacher = "list["+n+"].teacher"
            let time = "list["+n+"].time"
            let release_time = "list["+n+"].release_time"
            this.setData({
              [person]: classes[i].person_name,
              [class_name]: classes[i].class_name,
              [type]: classes[i].type,
              [teacher]: classes[i].teacher,
              [time]: classes[i].week + " " + classes[i].time,
              [release_time]: "2020/10/09"
            })
            n++;
          }
        }
      }
    })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})